10 / 22

How do you refetch data manually in RTK Query?

RTK Query automatically handles caching and background refetching, but it also allows you to manually trigger a refetch when needed. This is useful when data changes outside the app or after performing a mutation.

Ways to Manually Refetch Data
  1. 1
    1. Using the refetch method – Each query hook returns a refetch function that can be called to trigger a new request.
  2. 2
    1. Using useLazyQuery – Allows you to fetch data only when you explicitly trigger it.
  3. 3
    1. Invalidating cache tags – If using cache tags, mutations can invalidate queries, causing them to refetch automatically.
Example 1: Using the `refetch` Method
Example 2: Using `useLazyQuery` for Manual Fetching

Manual refetching gives developers fine-grained control over when data should be refreshed — ideal for pull-to-refresh, retry buttons, or after performing specific actions.